
from selenium import webdriver
class BasePage:

    chrome_driver = r"D:\20project\driver\95\chromedriver.exe"

    _driver = webdriver.Chrome(executable_path=chrome_driver)

    @classmethod
    def getUrl(cls, url):
        cls._driver.get(url)
        cls._driver.maximize_window()

    #定位元素的关键字
    @classmethod
    def locator_element(cls ,loc):
        return cls._driver.find_element(*loc)

    #设置值的关键字
    @classmethod
    def send_keys(cls,loc,value):
        cls.locator_element(loc).send_keys(value)

    #单机的关键字
    @classmethod
    def click(cls,loc):
        cls.locator_element(loc).click()

    #进入框架的关键字
    @classmethod
    def goto_frame(cls,frame_name):
        cls._driver.switch_to.frame(frame_name)

    #出框架关键字
    @classmethod
    def quit_frame(cls):
        cls._driver.switch_to.default_content()


    #获取文本的值
    @classmethod
    def get_value(cls,loc):
        return cls.locator_element(loc).text
    # #封装下拉框关键字
    # def choice_select(cls):





    #     login = cls._driver.find_elements_by_css_selector('#u1>a.lb')[0]
    #     login.click()
    #     sleep(3)
    #

    # def aa(cls):
    #     for handle in cls._driver.window_handles :
    #         cls._driver.switch_to.window(handle)
    #         print(cls._driver.title)
